//
//  SettingsViewController.m
//  GoodsBTS
//
//  Created by onemade on 14-9-19.
//  Copyright (c) 2014年 CNPC. All rights reserved.
//

#import "SettingsViewController.h"
#import "GoodsListController.h"
#import "AppDelegate.h"

@interface SettingsViewController ()<UIPickerViewDataSource,UIPickerViewDelegate>
{
    NSMutableArray *goodList;
    UIAlertView *alert;
}

@end

@implementation SettingsViewController

-(AppDelegate *)appDelegate
{
    return [[UIApplication sharedApplication] delegate];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    goodList = [[self appDelegate] GoodsList];
    // Do any additional setup after loading the view.
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

-(NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component
{
    return [goodList count];
}
-(NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component
{
    return [goodList[row] objectForKey:@"title"];
}
-(NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView
{
    return 1;
}


/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

- (IBAction)broadcasting:(id)sender {
    alert = [[UIAlertView alloc] initWithTitle:@"商品发布中.." message:nil delegate:self cancelButtonTitle:nil otherButtonTitles: nil];
    [alert setBackgroundColor:[UIColor blackColor]];
    [alert show];
    
    UIActivityIndicatorView *indicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
    
    // Adjust the indicator so it is up a few pixels from the bottom of the alert
    indicator.center = CGPointMake(alert.bounds.size.width / 2, alert.bounds.size.height - 50);
    [indicator startAnimating];
    [alert addSubview:indicator];
    [alert setValue:indicator forKey:@"accessoryView"];

//    indicator.center = CGPointMake(alerta.bounds.size.width / 2, alerta.bounds.size.height - 50);
    [self performSelector:@selector(close) withObject:self afterDelay:5];
}
-(void)close{
    
    [alert dismissWithClickedButtonIndex:0 animated:YES];
    
}
@end
